<template name="manuaAdd">
<view class="bgzd">
	<view class="form">
		<view class="form_top">
			<text>添加手工类目</text>
			<image @click="close" src="/static/img/none_close.png"></image>
		</view>
		<view class="page-section">
			<view class="weui-cells__title">类目名称:</view>
			<view class="weui-cells weui-cells_after-title">
				<view class="weui-cell weui-cell_input">
					<input class="weui-input" v-model="item.name"/>
				</view>
			</view>
		</view>
		<view class="page-section">
			<view class="weui-cells__title">价格:</view>
			<view class="weui-cells weui-cells_after-title">
				<view class="weui-cell weui-cell_input">
					<input class="weui-input" type="digit" v-model="item.price"/>
				</view>
			</view>
		</view>
		<view class="form_footer">
			<button v-if="addManualCateTrue" @click="add" class="strue">添加</button>
			<button v-else class="sfalse">添加</button>
		</view>
	</view>
</view>
</template>
<script>
import request from '@/util/request.js'
export default {
	name: "manuaAdd",
	//属性
	props:[],
	data() {
		return {
			addManualCateTrue:true,
			item:{
				name:'',
				price:''
			}
		}
	},
	//组件生命周期
	created:function(){
		//this.roleType = this.type
	},
	methods:{
		close:function(){
			console.log(222)
			this.$emit('func',{'name':'manuaAddShow','type':0})
		},
		add:function(){
			if(!this.item.name){
				uni.showToast({
					title: '请填写手工类目!!',
					icon: "none", 
					position:'bottom',
				});
			     return;
			}
			if(!this.item.price){
				uni.showToast({
					title: '请填写手工价格!!',
					icon: "none", 
					position:'bottom',
				});
			     return;
			}
			this.addManualCateTrue = false
			this.item.oa_id = uni.getStorageSync('oa_id')
			var that = this
			request({
				url: 'oa/manual/cateAdd',
				method: 'post',
				data:this.item,
				success: (res) => {
					if(res.data.code == 1){
						uni.showToast({
							title: '添加成功!!',
							icon: "none", 
							position:'bottom',
						});
						that.$emit('func',{'name':'manuaAddShow','type':1})
					}else{
						uni.showToast({
							title: '添加失败!!',
							icon: "none", 
							position:'bottom',
						});
						that.addRoleTrue = true
					}
				},
			})
		},
	}
}
</script>
<style>
.bgzd{
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.4);
	z-index:9999;
}
.form{
    padding-top:20rpx;
    padding-left:2%;
    width:100%;
    height:30%;
    bottom:0;
    padding-bottom: 20rpx;
    background:#d9d9d9;
    position: fixed;
}
.form_top{
    font-weight:bold;
    font-size:20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width:95%;
}
.form_top image{
    width:35rpx;height:35rpx;
    margin-right: 20rpx;
}
.form_footer{
    width:95%;
    margin-top:40rpx;
}

.page-section{
    width:96%;
    height:80rpx;
    line-height: 80rpx;
    margin-top:10rpx;
    display: flex;
    flex-direction: row;
    justify-content:flex-start;
	border-bottom: 1px dashed   #000000;
}
.weui-cells__title{
    width:25%;
	font-size:18px;
	text-align: center;
}
.weui-cells{
    width:70%;
    padding-top:5rpx;
	padding-left:10rpx;
}
.weui-input{
	width:100%;
}
.strue{
    width:100%;height:80rpx;line-height:80rpx;
    background:#ff861a;color:#fff;
}
.sfalse{
    width:100%;height:80rpx;line-height:80rpx;background:#8c8c8c;
    color:#fff;
}
</style>